<?php

include "../database.php";
/* Create and populate the pData object */
$hoursRemaining = burnDown("hours_remaining");
//Work remaining on specific date
$workToDo = array();
//Workload, "new project time estimate"
$workload = burnDown("hours_spent");
//All dates
$date = array();
//Counting dates
$count = array();
//Ideal workrate
$ideal = array();

//GET first value of remaining time
$values = array_values($hoursRemaining);
$firstValue = array_shift($values);
$lastValue = end($values);
//Decreasing idealy if we would work "perfectly"
$koeficient = ($firstValue - $lastValue) / count($hoursRemaining);

$i = 1;

foreach ($hoursRemaining as $key => $val) {
    $ideal[] = ($firstValue - $koeficient * $i) + $lastValue;
    $workToDo[] = $val;
    $date[] = $key;
    $count[] = $i;
    $i++;
}
print_r($date);
echo "+++++++<br /> <br />";
$sprints = getSprints();
print_r($sprints);

$sprint_indexes = array();
$sprint_titles = array();
$i=1;
foreach ($sprints as $key => $val) {
    $ind = array_search($val, $date);
    //If that date does not exist
    if ($ind ==0 || $ind != NULL) {
        $sprint_indexes[] = $ind;
        $sprint_titles[] = "Sprint $i";
        $i++;
    }
}
print_r($hoursRemaining);
print_r($workload);
echo "<br /><table>";
$i=0;
foreach($hoursRemaining as $key => $hours){
    echo "<tr><td>$key</td><td>$hours</td><td>$workload[$i]</td></tr>";
    $i++;
}
echo "< /table>";
?>
